package com.bac.rentmap.ad.flat.rating.item;

import java.util.Date;
import java.util.logging.Logger;

import com.bac.rentmap.ad.flat.FlatAd;

public class LastPublishingDateRatingItemCalculator implements
		RatingItemCalculator {
	private static final Logger log = Logger
			.getLogger(LastPublishingDateRatingItemCalculator.class.getName());

	public long calculate(FlatAd flatAd) {
		Date lastPublishingDate = flatAd.getLastPublishingDate();
		long res;
		if (lastPublishingDate != null) {
			res = DateRatingHelper.getDateRating(lastPublishingDate);
		} else {
			// TODO: remove
			log.warning("Last publishing date is not set for " + flatAd);
			res = 0;
		}
		log.finest("Last publishing date rating: " + res);
		return res;
	}

	public long getMaxPossibleRating() {
		return DateRatingHelper.getMaxDateRating();
	}

	/**
	 * week ago
	 */
	public long getMinPossibleRating() {
		return DateRatingHelper.getMinDateRating();
	}
}
